#!/usr/bin/env bash
set -e
set -u
set -o pipefail


sorting_main() {
    array=('z' 'd' 'c' 'f' 'zz')


    # works, but lint
    # IFS=$'\n' sorted=("$(sort --reverse <<<"${array[*]}")"); unset IFS


    # doesn't work
    # IFS=$'\n' read -d '' -r -a sorted < <(printf '%s\n' "${array[@]}" | sort)


    readarray -t sorted < <(printf '%s\n' "${array[@]}" | sort --reverse)

    for foo in "${sorted[@]}"
    do
        echo "${foo}"   
    done

}


sorting_main
